package com.cysion.study.ui

import android.view.View
import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.ktbox.utils.whiteTextTheme
import com.cysion.other.color
import com.cysion.other.startActivity_ex
import com.cysion.targetfun._subscribe
import com.cysion.study.uibox.bar.TopBar
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.R
import com.cysion.study.constant.BUNDLE_KEY
import com.cysion.study.helper.UserCache
import com.cysion.study.net.ApiClient
import com.cysion.study.widget.ShowToast
import kotlinx.android.synthetic.main.activity_leve_comment.*

//考级评定
class LeveCommentActivity : BaseActivity(), View.OnClickListener {

    override fun getLayoutId(): Int = R.layout.activity_leve_comment

    private var curPage = 1
    private var pageType = ""
    override fun initView() {
        val bundleExtra=intent.getBundleExtra(BUNDLE_KEY)
//        pageType = bundleExtra.getString("pageType")
        whiteTextTheme(color(R.color.main_cl))
         topbar.apply {
            setTitle("考级评定")
//            setTexts("添加", TopBar.Pos.RIGHT)
            setOnTopBarClickListener { obj, pos ->
                if (pos == TopBar.Pos.LEFT) {
                    finish()
                }else if (pos == TopBar.Pos.RIGHT) {
//                    startActivity_ex<AddKnowActivity>()//添加习题与知识

                    /*AlertSearch.search(self,""){ confirm: Int, start: String, end: String ->
                        CLog.i("@@@搜索="+start+end)
                        curPage=1
                        getDataList(curPage,start,end)
                    }*/
                }
            }
        }
        tv_submit.setOnClickListener {
            finish()
        }
        tv_sign.setOnClickListener(this)
    }
    //加载数据
    override fun initData() {
        super.initData()

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.tv_sign->{
                startActivity_ex<LeveSignActivity>()//去签名
            }
        }

    }




    private fun getDataList(page: Int, start: String, end: String) {
        Alert.loading(self)
        ApiClient.api.getTutorOrderList(UserCache.token,"",curPage.toString()).compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()


                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)

                }
            }

    }




    override fun closeMvp() {
    }

}
